home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / qformat.zip / QFORMAT.8 < prev    next >
Text File  |  1987-11-30  |  11KB  |  354 lines

  1. ;QuickFormat for MS-DOS
  2. ;November 30, 1987 version 5
  3. ; by Ted Beach ---  TSR version 
  4.  
  5.  
  6. cseg           segment
  7.                assume cs:cseg,ds:cseg,es:cseg,ss:cseg
  8.  
  9. org            0100h
  10. start:         jmp setup
  11.                db "qformat by Ted Beach" ; id string for install
  12.  
  13. format$loop:   
  14.                db 0cdh        ;interrupt op code
  15. oldint         db 0           ;do old interrupt first  
  16.                pushf          ;save flags  
  17.                cmp b cs:busy,1
  18.                jz exit1
  19.                push ax        ; save character
  20.                push bx        ; and registers we
  21.                push ds        ; will be atlering for the test
  22.                xor bx,bx
  23.                mov ds,bx
  24.                mov bx,417h
  25.                cmp byte ptr [bx],7
  26.                jnz exit
  27.                mov b cs:busy,1
  28.  
  29.                cli
  30.                mov byte ptr [bx],0
  31.                mov cs:our$stack,sp
  32.                mov cs:sseg,ss
  33.                mov bx,cs
  34.                mov ss,bx
  35.                mov sp,offset our$stack
  36.                sti
  37.  
  38.                push cx
  39.                push dx
  40.                push si
  41.                push di
  42.                push es
  43.                mov ds,bx
  44.                mov es,bx
  45.                cld
  46.                call format
  47.                pop es
  48.                pop di
  49.                pop si 
  50.                pop dx
  51.                pop cx
  52.  
  53.                cli
  54.                mov ss,cs:sseg
  55.                mov sp,cs:our$stack
  56.                mov b cs:busy,0
  57.                sti
  58.  
  59. exit:          pop ds
  60.                pop bx
  61.                pop ax
  62. exit1:         popf
  63.                iret
  64.  
  65. ; subroutines follow
  66.  
  67. format:        
  68.                mov ax,27h
  69.                mov dx,0201h
  70.                mov di,offset buf
  71.                mov cx,9
  72.  
  73. init$loop:     stosw
  74.                xchg dx,ax
  75.                stosw
  76.                inc ax
  77.                xchg dx,ax
  78.                loop init$loop
  79.  
  80.                mov cx,40      ; do 40 cylinders
  81.                mov b err,0      ; clear error flag
  82.  
  83. format$loop1:  push cx
  84.                xor dx,dx
  85.                call format$track
  86.                test b err,1
  87.                jnz fmterr
  88.                test b format$type,2
  89.                jnz single
  90.                call chg$sides
  91.                mov dx,0100h
  92.                call format$track
  93.                test b err,1
  94.                jnz fmterr
  95.                call chg$sides
  96.  
  97. single:        call next$track
  98.                pop cx
  99.                loop format$loop1
  100.  
  101. ;  next write boot sector and FAT1
  102.  
  103.                xor dx,dx
  104.                mov bx,offset sector1
  105.                mov cx,1
  106.                mov ax,0302h
  107.                int 13h
  108.                jc error
  109.  
  110. ;  next write FAT2 sector
  111.  
  112.                mov bx,offset sector2
  113.                mov ax,0301h
  114.                mov cx,4
  115.                test b format$type,1
  116.                jz sect9
  117.                dec cx         ; 8 sectors
  118. sect9:         int 13h
  119.                jc error
  120.                ret
  121.  
  122. fmterr:        pop cx
  123. error:         mov dl,7
  124.                mov ah,2
  125.                int 21h
  126.                clc
  127.                ret
  128.  
  129. chg$sides:     push cx
  130.                mov cx,9
  131.                mov bx,offset buf+1
  132. cs1:           xor byte ptr [bx],1
  133.                add bx,4
  134.                loop cs1
  135.                pop cx
  136.                ret
  137.  
  138. next$track:    push cx
  139.                mov cx,9
  140.                mov bx,offset buf
  141. nt1:           dec byte ptr[bx]
  142.                add bx,4
  143.                loop nt1
  144.                pop cx
  145.                ret
  146.  
  147. format$track:  push cx
  148.                mov bx,offset buf
  149.                mov ax,0509h
  150.                test b format$type,1
  151.                jz  ft1
  152.                dec ax
  153. ft1:           mov ch,[bx]
  154.                mov cl,1
  155.                int 13h
  156.                jnc ok
  157.                mov b err,1
  158. ok:            pop cx
  159.                ret
  160.  
  161.  
  162.  
  163.  
  164.  
  165. err:           db 0
  166. format$type:   db 0
  167. buf            db 9*4 dup (0)
  168.  
  169. sector1:
  170.      db   0E9h,023h,001h,"QFORM"
  171.      db    "AT1",00,02,02,01,00
  172.      db    02,70h,00,0d0h,02,0fdh,02,0
  173.      db    00,09,00,02,00,00h,000h,000h  
  174.      db    00h,000h,000h,000h,000h,000h,000h,000h
  175.      db    00h,000h,000h,000h,000h,000h,000h,000h
  176.      db    00h,000h,000h,000h,000h,000h,000h,000h
  177.      db    07h,00Dh,00Ah,04Eh,06Fh,06Eh,02Dh,073h
  178.      db    79h,073h,074h,065h,06Dh,020h,064h,069h
  179.      db    73h,06Bh,020h,06Fh,072h,020h,064h,069h
  180.      db    73h,06Bh,020h,065h,072h,072h,06Fh,072h
  181.      db    2Eh,00Dh,00Ah,052h,065h,070h,06Ch,061h
  182.      db    63h,065h,020h,064h,069h,073h,06Bh,020h
  183.      db    61h,06Eh,064h,020h,073h,074h,072h,069h
  184.      db    6Bh,065h,020h,061h,06Eh,079h,020h,06Bh
  185.      db    65h,079h,00Dh,00Ah,024h,049h,04Fh,020h
  186.      db    20h,020h,020h,020h,020h,053h,059h,053h
  187.      db    4Dh,053h,044h,04Fh,053h,020h,020h,020h
  188.      db    53h,059h,053h,053h,08Ah,0E0h,0A0h,018h
  189.      db    7Ch,02Ah,0C1h,0FEh,0C0h,02Ah,0E0h,077h
  190.      db    04h,002h,0C4h,032h,0E4h,050h,08Ah,0E1h
  191.      db    8Bh,0CFh,0D0h,0CDh,0D0h,0CDh,086h,0CDh
  192.      db    0Ah,0CCh,0E8h,042h,000h,052h,098h,0F7h
  193.      db    26h,00Bh,07Ch,003h,0D8h,05Ah,058h,00Ah
  194.      db   0E4h,074h,00Fh,0B1h,001h,0FEh,0C6h,03Ah
  195.      db    36h,01Ah,07Ch,072h,0C9h,032h,0F6h,047h
  196.      db   0EBh,0C4h,05Bh,0C3h,057h,0B9h,00Bh,000h
  197.      db   0F3h,0A6h,05Fh,075h,032h,052h,026h,08Bh
  198.      db    55h,01Eh,026h,08Bh,045h,01Ch,00Bh,0D2h
  199.      db    75h,025h,08Bh,0C8h,0F7h,036h,00Bh,07Ch
  200.      db    0Bh,0D2h,074h,001h,040h,05Ah,0C3h,0BEh
  201.      db    03h,000h,0B4h,002h,050h,0CDh,013h,073h
  202.      db    0Ch,04Eh,074h,00Bh,0B4h,000h,0CDh,013h
  203.      db    72h,005h,058h,0EBh,0EFh,058h,0C3h,0BEh
  204.      db    38h,07Ch,0ACh,03Ch,024h,074h,009h,0B4h
  205.      db    0Eh,0BBh,007h,000h,0CDh,010h,0EBh,0F2h
  206.      db   0B4h,000h,0CDh,016h,0CDh,019h,0FCh,08Ch
  207.      db   0C8h,0FAh,08Eh,0D0h,0BCh,0F4h,07Fh,0FBh
  208.      db    8Eh,0D8h,08Eh,0C0h,01Eh,0C5h,036h,026h
  209.      db    7Ch,0C5h,034h,0BFh,000h,07Ch,0B9h,00Bh
  210.      db    00h,0F3h,0A4h,01Fh,0A1h,02Ch,07Ch,0A2h
  211.      db    04h,07Ch,088h,026h,007h,07Ch,0C4h,03Eh
  212.      db    26h,07Ch,0B8h,000h,07Ch,0ABh,08Ch,0D8h
  213.      db   0ABh,08Ah,036h,02Eh,07Ch,08Bh,03Eh,02Fh
  214.      db    7Ch,08Ah,00Eh,031h,07Ch,0B0h,001h,0C4h
  215.      db    1Eh,022h,07Ch,0E8h,025h,0FFh,08Bh,0FBh
  216.      db   0BDh,00Fh,000h,026h,0F6h,045h,00Bh,008h
  217.      db    75h,00Ch,0BEh,07Dh,07Ch,0B9h,00Bh,000h
  218.      db    57h,0F3h,0A6h,05Fh,074h,008h,083h,0C7h
  219.      db    20h,04Dh,075h,0E7h,0EBh,081h,0E8h,04Ch
  220.      db   0FFh,081h,0F9h,000h,075h,077h,0F5h,095h
  221.      db    83h,0C7h,020h,0BEh,088h,07Ch,0E8h,033h
  222.      db   0FFh,095h,08Ah,036h,032h,07Ch,08Bh,03Eh
  223.      db    33h,07Ch,08Ah,00Eh,035h,07Ch,0C4h,01Eh
  224.      db    1Eh,07Ch,0E8h,0DEh,0FEh,0CDh,011h,091h
  225.      db   0D0h,0C1h,0D0h,0C1h,081h,0E1h,003h,000h
  226.      db    75h,001h,041h,041h,033h,0C0h,0F6h,0C2h
  227.      db    80h,074h,002h,08Bh,0C1h,08Bh,01Eh,036h
  228.      db    7Ch,0FFh,02Eh,01Eh,07Ch,000h,000h,000h
  229.      db    00h,000h,000h,000h,000h,000h,000h,000h
  230.      db    00h,000h,000h,000h,000h,000h,000h,000h
  231.      db    00h,000h,000h,000h,000h,000h,000h,000h
  232.      db    00h,000h,000h,000h,000h,000h,000h,000h
  233.      db    00h,000h,000h,000h,000h,000h,055h,0AAh
  234.  
  235.  
  236. sector2        db 0fdh,0ffh,0ffh
  237.                db 509 dup (0)
  238.  
  239.                db 60 dup ("STACK")
  240. our$stack      dw (0)
  241. sseg           dw (0)
  242. busy:          db (0)
  243.  
  244.  
  245. setup:         mov ax,351eh
  246.                int 21h        ; disk base table in es:bx
  247.                mov ax,es
  248.                cmp ax,0a000h
  249.                jb doit
  250. erexit:        mov  dx,offset installnot
  251.                mov ah,9
  252.                int 21h
  253.                int 20h
  254.  
  255. doit:          cld
  256.                mov b format$type,0
  257.                mov si,081h
  258. parse$loop:    lodsb
  259.                cmp al,0dh
  260.                jz  get$vec
  261.                cmp al,"1"
  262.                jnz  p1
  263.                or b format$type,2
  264.                jmp parse$loop
  265. p1:            cmp al,"8"
  266.                jnz parse$loop
  267.                or b format$type,1
  268.                jmp parse$loop
  269.  
  270. get$vec:       mov ax,351eh
  271.